package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/21/13
 * Time: 9:08 AM
 * To change this template use File | Settings | File Templates.
 */
public class Book {
    private boolean reserved;
    private String name;

    public Book(String name)
    {
        this.name = name;
    }

    public void setName(String name) {
         this.name = name;
    }

    public String getName()
    {
        return this.name;
    }

    public boolean isReserved()
    {
        return reserved;
    }

    public boolean reserve(){
      boolean wasReserved = !reserved;
      if(!reserved)
          reserved= true;
      return wasReserved;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (name != null ? !name.equals(book.name) : book.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
